package cxm.mmp.aud;


public class WebSocketRecordingReader implements IRecordingSource {
	RecordingDataAdaper dataAdapter = null;
	public WebSocketRecordingReader(RecordingDataAdaper adapter) {
		if (null == adapter)
			throw new NullPointerException("connect");
		
		this.dataAdapter = adapter;
	}
	
    // do before data transfer, success to return 0
 	public int onRecordStart() {
 		// remain empty, no need for create connection
 		return 0;
 	}
 	
 	// do manipulate recording data
 	// return data processed, less than 0 for error
 	public int onRecordData(byte []data, int start, int num) {
 		// copy data received from web socket
 		return this.dataAdapter.getData(data, start, num);
 	}
 	
 	// do after data transfer, success to return 0
 	public int onRecordStop() {
 		// remain empty, no need for disconnecting
 		return 0;
 	}
 	
 	public int onRecordError(RecordError error, int errno) {
 		return 0;
 	}
}
